﻿// set_sn_dlg.cpp: 实现文件
//

#include "pch.h"
#include "afxdialogex.h"
#include "set_sn_dlg.h"
#include "ProjectAA.h"
#include "resource.h"



// CSetSnDlg 对话框

IMPLEMENT_DYNAMIC(CSetSnDlg, CDialogEx)

CSetSnDlg::CSetSnDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_SET_BARCODE, pParent)
{
	
}

CSetSnDlg::~CSetSnDlg()
{
}

void CSetSnDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CSetSnDlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, &CSetSnDlg::OnBnClickedButtonSave)
END_MESSAGE_MAP()


// CSetSnDlg 消息处理程序


BOOL CSetSnDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	this->InitClassData();

	this->InitUiData();

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}


void CSetSnDlg::InitClassData()
{
	this->needScanBarcode = (CButton*)GetDlgItem(IDC_CHECK_CHECK_BARCODE2);
	this->checkCheckBarcode = (CButton*)GetDlgItem(IDC_CHECK_CHECK_BARCODE);
	this->editSnLen = (CEdit*)GetDlgItem(IDC_EDIT_SN_LEN);
	this->editCpLen = (CEdit*)GetDlgItem(IDC_EDIT_CP_LEN);
	this->editSnWith = (CEdit*)GetDlgItem(IDC_EDIT_SN_WITH);
	this->editCpWith = (CEdit*)GetDlgItem(IDC_EDIT_CP_WITH);
}


void CSetSnDlg::InitUiData()
{
	this->needScanBarcode->SetCheck(gSystemMgr.needScanBarcode);
	this->checkCheckBarcode->SetCheck(gSystemMgr.checkBarcode);
	SetDlgItemInt(IDC_EDIT_SN_LEN,gSystemMgr.SnLen);
	this->editSnWith->SetWindowTextW(gSystemMgr.SnWith);
	SetDlgItemInt(IDC_EDIT_CP_LEN, gSystemMgr.CpLen);
	this->editCpWith->SetWindowTextW(gSystemMgr.CpWith);
}


void CSetSnDlg::OnBnClickedButtonSave()
{
	gSystemMgr.needScanBarcode = this->needScanBarcode->GetCheck();
	gSystemMgr.checkBarcode = this->checkCheckBarcode->GetCheck();
	gSystemMgr.SnLen = GetDlgItemInt(IDC_EDIT_SN_LEN);
	this->editSnWith->GetWindowTextW(gSystemMgr.SnWith);
	gSystemMgr.CpLen = GetDlgItemInt(IDC_EDIT_CP_LEN);
	this->editCpWith->GetWindowTextW(gSystemMgr.CpWith);
	
	gSystemMgr.configBarcode.SaveValueList();
}
